<template>
  <div class="main">
       <div class="top">
      <div class="back" @click="onClickLeft('/')">
        <img src="../assets/img/back.png" alt=""  />
      </div>
      <div class="title">
      {{$t('m.我的推广')}}
      </div>
    </div>  
    <div class="list"> 
      <div class="list-item">       
            <div v-for="(item, i) in list" :key="i"   class="item">
              <div class="items" @click="toshow(i,item.show)">  
             <div class="line">            
            <div class="left">{{ $t("m.用户地址")}} </div>
            <div class="right">{{ item.userAddress | yingcang}}</div>
            </div>
             </div>
             <div class="items " v-if="item.show">  
            <div class="line fadeInLeft">            
            <div class="left">{{ $t("m.用户等级") }}  </div>
            <div class="right">V{{ item.userLevel>0?item.userLevel:'0' }}</div>
            </div>
            <div class="line fadeInLeft">            
            <div class="left">{{ $t("m.社区等级") }}  </div>
            <div class="right">{{LevleName(item.userLevelB)}}</div>
            </div>
            <div class="line fadeInLeft">            
            <div class="left">{{$t('m.节点等级')}} </div>
            <div class="right">{{ item.isNode?$t('m.是'):$t('m.否') }} 
            </div>
            </div>
            <div class="line fadeInLeft">            
            <div class="left">{{$t('m.grtred')}} </div>
            <div class="right">{{ dexc(item.totalInvest)||'0' }}</div>
            </div>           
           <div class="line fadeInLeft">            
            <div class="left">{{$t('m.zttred')}} </div>
            <div class="right">{{ dexc(item.recPerformance)||'0' }}</div>
            </div>
            <div class="line fadeInLeft">            
            <div class="left">{{$t('m.sqtred')}} </div>
            <div class="right">{{ dexc(item.communityPerformance)||'0' }} 
            </div>
            </div>
            </div>
          </div>
              <div v-if="list.length==0"  class="noData">
                  <img src="../assets/img/logo.png" alt="" >
                  <!-- <div class="ttx">Tfilm</div> -->
                </div>
      </div>
      <Loadings v-if="loading"/>
    </div>
  </div>
</template>

<script>
import {getDirectReferralsInfo} from '@/api/Public'
import Loadings from '@/components/loading.vue'
import Web3 from 'web3'
export default {
  data() {
    return {
      userWallet: "",
      list: [],
      total: 0,
      page: 1,
      loading: false,

    };
  },
components: {Loadings},
  computed: {
    dqyy() {
      if (this.$store.getters.language) {
        return this.$store.getters.language;
      } else {
        return "zh-CN";
      }
    }
  },
  filters: {
    yingcang(val) {
      if (val) {
        let a = val.replace(/(\w{8})\w+(\w{8})/, "$1...$2");
        return a;
      } else {
        return "";
      }
    },
  },
  beforeCreate() {
    // var a = setInterval(() => {
    //   if (typeof window.ContractEth !== "undefined") {
    //     this.getlist();
    //     clearInterval(a);
    //   } else {
    //     set();
    //   }
    // }, 1000);
  },
  created() {
    this.userWallet =this.$store.getters.userWallet;
    this.getList()
  },
   watch: {
    "$store.getters.userWallet": function (val) {
       this.onClickLeft('/')
    },
    deep: true,
    immediate: true,
  },
  methods: {
    dexc(val){
    if(val){
      let  ethereum = window.ethereum
    let web3s = new Web3(ethereum);
      let amount=  web3s.utils.fromWei(val +'', 'ether'); 
      // let num =val/Math.pow(10,18)
      return val? Math.floor(amount*1000000)/1000000:'0'
    }else{
      return 0
    }
    },
    LevleName(val){
      switch (val) {
        case 1:
          return this.$i18n.t('m.社区')
          break;
          case 2:
          return this.$i18n.t('m.战区联创')
          break;
          case 3:
          return this.$i18n.t('m.系统联创')
          break;
        default:
          return this.$i18n.t('m.普通会员')
          break;
      }
    },
    onClickLeft(val) {
       this.$router.replace({ path:val})
    },
    async getList() {
      this.loading=true
      getDirectReferralsInfo(this.userWallet).then(res=>{
        console.log(res);
        this.loading=false
        if(res){
        this.list = res.map((el,i)=>{
            let obj=Object.assign({},el)
            obj.show=false
            return obj
          })
          console.log(this.list);
        }
      })  
    },
    toshow(i,val) {
      this.$set(this.list[i],'show',!val)
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../../src/assets/scss/_handle.scss";
$t-mf: "PingFang";
$t-f: "DINAlternate-Bold";
.main {
    background:  #161628 url("../assets/img/dsbg.jpg")  fixed no-repeat;
  // background: #0F112A;
  background-size:cover;
  background-position: top center;
  // overflow-x: hidden;
  width: 750px;
  margin: 0 auto;
  min-height: 100vh;
  ::v-deep.van-nav-bar__content {
    height: 80px !important;
  }
  ::v-deep.van-nav-bar__arrow {
    font-size: 36px;
  }
  ::v-deep.van-ellipsis {
    font-size: 32px;
    line-height: 44px;
  }
 .top { background: #012f2bbf;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 28px;
    height: 96px;
    margin: 0 auto;
    color: #fff;
     border-bottom: 1px solid #1cc10e;
        position: relative;
      .back {
      position: absolute;
    left: 20px;
       width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;

      img {
        height: 50px;
        width: 50px;
      }
      .icosn {
        height: 36px;
        margin-right: 5px;
        width: 36px;
      }
    }
    .title{
         background: linear-gradient(234deg,#ffffff, #ffffff);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      font-size: 36px;
      font-weight: 600;
      font-family: $t-f;
    }

    .navbtn {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 150px;
      .img {
        width: 36px;
        height: 30px;
      }
      .img2 {
        width: 36px;
        height: 36px;
        margin: 0 36px;
      }
      .lang {
        font-size: 22px;
        font-family: $t-mf;
        font-weight: 600;
        @include font_color("font_color3");
        line-height: 42px;
        // margin-left: 20px;
      }
    }
  }
   .mdex{
    font-size: 24px;
    color: #fff;
    background: rgba(0 0 0 / 24%);
    margin: 0 0 20px;
    padding: 20px;
    border-top:1px solid  #6d6d6d
  }
  .card {
    // width: 652px;
    // background: linear-gradient(18deg, #ffdf2d, #00e2be);
    // border-radius: 20px;
    // padding: 20px;
    // margin: 20px auto;
      width: 694px;
      height: 100%;
      background:#381b7c;// #262626;
      border-radius: 20px;
      margin: 28px auto;
      padding: 8px 0 20px;
       color:#000;
// border: 2px solid #aee1ae;
.title {
        margin-left: 50px;
        margin-right: 28px;
        height: 66px;
        font-size: 40px;
        font-family: $t-mf;
        font-weight: 600;
        color: #ffffff;
        line-height: 66px;
        text-align: left;
        display: flex;
        align-items: center;
        justify-content: space-between;       
        .node {
          font-size: 30px;
          font-weight: 600;
          color: #8B8B94;
          line-height: 32px;
        }
      }
  .lists {
        display: flex;
        justify-content: space-around;
        align-items: center;
        .item {
          flex: 1;
          overflow: hidden;
 .num {
        margin-top: 12px;
        font-size: 32px;
        font-family: $t-f;
        font-weight: bold;
        background: linear-gradient(234deg,#e4005e, #b4184c);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        white-space: nowrap;
        overflow-x: auto;
        padding: 0 20px;
        overflow-y: hidden;
      }
      .tt {
        font-size: 28px;
        font-family: $t-mf;
        font-weight: 600;
        color:#888888;
        line-height: 30px;
        margin-top: 12px;
      }
        }
      }
    .tips {
      font-size: 24px;
      font-family: $t-mf;
      font-weight: 400;
      color: #ffffff;
      line-height: 34px;
      text-align: left;
      margin: 22px 0 0;
    }
    .btns {
      width: 638px;
      height: 80px;
      background: #000000;
      border-radius: 40px;
      font-size: 32px;
      font-family: $t-mf;
      font-weight: 600;
      color: #ffffff;
      line-height: 80px;
      margin: 18px auto 20px;
    }
  }
    .stitle{
      font-weight: 600;
      font-size: 28px;
      margin: 20px auto;
      text-align: center;
      width: 200px;
      padding: 10px;
      border-radius: 30px 0;
      color:#ffffff;
          border: 2px solid #62e187;
    }
  .list {
    width: 696px;
    height: calc(100vh - 100px);
    // background: #0a0a0ab5;
    border-radius: 20px;
    margin: 0px auto;
    overflow: auto;

     ::v-deep.van-list{
      height: 100vh;
    overflow: auto;
    }
    .title{
      font-weight: 600;
      font-size: 28px;
      margin: 20px auto;
      text-align: center;
      width: 200px;
      padding: 10px;
      border-radius: 30px 0;
      color:#ffffff;
          border: 2px solid #62e187;
    }
    .list-top {
      display: flex;
      align-items: left;
      justify-content: space-between;
      margin: 50px 0 0;
      border-top: 1px solid #f8f8f8;
      border-bottom: 1px solid #f8f8f8;
      padding: 30px 30px 30px;
      div {
        font-size: 24px;
        font-family: $t-mf;
        font-weight: 600;
        color: #8b8b93;
        line-height: 34px;
        text-align: left;
        white-space: nowrap;
        margin: 0 5px;
      }
    }
    .list-item {
      width: 100%;
      div {
        font-size: 24px;
        font-family: $t-f;
        font-weight: 400;
        color: #666666;
        line-height: 34px;
        text-align: left;
        // margin: 0 5px;
        white-space: nowrap;
        flex: 1;
        .fuzhi {
          background: transparent;
          border: none;
          width: 30px;
        }
        .fz {
          width: 28px;
          height: 26px;
          margin: 0 -5px;
        }
      }
      .item {
        display: flex;
        justify-content: space-between;
        flex-direction: column;
      align-items: center;
      background: #00000070;
      border: 1px solid #34C717;
      border-radius: 8px;
      margin: 18px 0;
      padding: 8px 18px;
      font-weight: 400;
      font-size: 28px;
      font-family: $t-f;
        .items{
         display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
      flex-direction: column;
      .line{
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin: 10px;
        width: 100%;
        flex: 1;
        .left {
        text-align: left;
          font-size: 22px;
          font-family: $t-mf;
          font-weight: 400;
          color: #f8f8f8;
          line-height: 32px;
      }
      .right {
        font-size: 22px;
        font-family: $t-f;
        font-weight: 600;
        color: #0af347;
        line-height: 32px;
            text-align: right;
            display: flex;
            justify-content: flex-end;
            .set{
              margin-left: 10px;
              border: 1px solid #ffffff;
              padding: 0 10px;
              border-radius: 10px;
            }
      }
      }}
      }
    }
    .d1 {
      width: 50%;
    }
    .d2 {
      width: 50%;
      text-align: right !important;
    }
  }
  .popup {
    width: 672px;
    background: #ffffff;
    border-radius: 30px;
    ::v-deep.van-list{
      height: 50vh;
    overflow: auto;
    }
    .title {
      font-size: 48px;
      font-family: $t-mf;
      font-weight: 600;
      color: #222222;
      line-height: 66px;
      margin: 44px auto;
    }
    .xztype{
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-direction: column;
       ::v-deep .van-stepper__input{
          font-size: 42px;
        }
        .item{
        width: calc(100% - 200px);
      font-size: 30px;
      font-family: $t-f;
      font-weight: 400;
      color: #333333;
      text-align: left;
      padding: 0px 10px;
      display: flex;
      align-items: center;
      overflow: hidden;
      margin: 20px 10px 0;
      justify-content: center;
            
        }
        .act{
               background:linear-gradient(315deg, #060b0c 0%, #0e4942 74%, #121212 100%);
        // border-radius: 10px;
        color: #ffffff;
        }
    }
      .btn {
     width: calc(100% - 200px);
      height: 80px;
      font-size: 32px;
      font-family: $t-mf;
      font-weight: 600;
      color: #ffffff;
      line-height: 80px;
      margin: 54px auto;
background: #b4184c;
box-shadow: 0px 4px 16px 4px rgba(207,182,247,1);
// border-radius: 40px;
border: none;
  display: flex;
      align-items: center;
      justify-content: center;
    }
    }
  .mentop {
    display: flex;
    justify-content: space-between;
    margin: 44px 30px;
    .logo {
      // height: 82px;
      width: 232px;
    }
    .gb {
      height: 40px;
      width: 40px;
      margin-right: 8px;
    }
  }
  .menulist {
    margin-top: 100px;
    .menuitem {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin: 44px;
      border-bottom: 1px solid #f8f8f8;
      padding-bottom: 30px;
      .left {
        flex: 1;
        text-align: left;
        display: flex;
        img {
          height: 48px;
          width: 48px;
        }
        .txt {
          margin-left: 40px;
          font-size: 36px;
          font-family: $t-mf;
          font-weight: 600;
          @include font_color("font_color1");
          line-height: 50px;
        }
      }
      .right {
        img {
          height: 38px;
          width: 26px;
        }
      }
    }
      .act{
       .txt {
         color: #2f73fd !important;
       }
    }
  }
  .buttoms {
      height: 28px;
      font-size: 24px;
      font-family: $t-f;
      font-weight: bold;
      color: #999999;
      line-height: 28px;
      margin: 80px auto 0;
      padding-bottom: 20px;
      width: 100%;
      position: relative;
      bottom: 0;
      left: 50%;
      transform: translateX(-50%);
    }
       .noData{
		width: 100%;
		display: flex;
		align-items: center;
		flex-direction: column;
		justify-content: center;
		img{
			width: 242px;
			margin: 150px auto 20px;
		}
     .ttx{
      font-size:32px;
      color: #ffffff !important;
  font-family: $t-f;
   font-weight: bold;
    }
	}
}
</style>